// Mask
$(".jquery_preco").setMask({mask: "99999"});
$(".jquery_tempo").setMask({mask: "99999"});
$(".jquery_quantidade").setMask({mask: "999999"});


$("input[name=numero]").setMask({mask: "99999"});
$("input[name=cep]").setMask({mask: "99.999-999"});

$("input[name=telefone]").setMask({mask: "(99) 9999-9999"});
$("input[name=telefone]").keyup(function () {
  var t = $(this),
      n = t.val();
  if (n[1] == "1" && n[2] == "1" && n[5] == "9") {
      t.setMask({
          mask: "(99) 99999-9999"
      })
  } else {
      t.setMask({
          mask: "(99) 9999-9999"
      })
  }
});

/*
* Validacoes
*/
{
    
    $.validator.addMethod("uniqueUserName", function(value, element) {

        var unique = true,
            my_ajax_script = {"ajaxurl":"..\/Ajax?tipo=usuario&acao=consulta"};

        jQuery.ajax({
         url: my_ajax_script.ajaxurl,
         data: ({campo: 'email', valor: value}),
         async: false, 
         success: function(data) {
          unique = data === "true" ? true : false;
         }
        });

        return unique;

      }, "E-mail já cadastrado.");

    
} // end Validacoes;